home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / DESC.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  62 lines

  1. #ifndef __ARCH_DESC_H
  2. #define __ARCH_DESC_H
  3.  
  4. struct desc_struct {
  5.     unsigned long a,b;
  6. };
  7.  
  8. extern struct desc_struct gdt_table[];
  9. extern struct desc_struct *idt, *gdt;
  10.  
  11. struct Xgt_desc_struct {
  12.     unsigned short size;
  13.     unsigned long address __attribute__((packed));
  14. };
  15.  
  16. #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
  17. #define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
  18.  
  19. /*
  20.  * Entry into gdt where to find first TSS. GDT layout:
  21.  *   0 - null
  22.  *   1 - not used
  23.  *   2 - kernel code segment
  24.  *   3 - kernel data segment
  25.  *   4 - user code segment
  26.  *   5 - user data segment
  27.  *   6 - not used
  28.  *   7 - not used
  29.  *   8 - APM BIOS support
  30.  *   9 - APM BIOS support
  31.  *  10 - APM BIOS support
  32.  *  11 - APM BIOS support
  33.  *  12 - TSS #0
  34.  *  13 - LDT #0
  35.  *  14 - TSS #1
  36.  *  15 - LDT #1
  37.  */
  38. #define FIRST_TSS_ENTRY 12
  39. #define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
  40. #define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
  41. #define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
  42. #define load_TR(n) __asm__ __volatile__("ltr %%ax": /* no output */ :"a" (_TSS(n)))
  43. #define load_ldt(n) __asm__ __volatile__("lldt %%ax": /* no output */ :"a" (_LDT(n)))
  44. #define store_TR(n) \
  45. __asm__("str %%ax\n\t" \
  46.     "subl %2,%%eax\n\t" \
  47.     "shrl $4,%%eax" \
  48.     :"=a" (n) \
  49.     :"0" (0),"i" (FIRST_TSS_ENTRY<<3))
  50.  
  51. extern void set_intr_gate(unsigned int irq, void * addr);
  52. extern void set_ldt_desc(unsigned int n, void *addr, unsigned int size);
  53. extern void set_tss_desc(unsigned int n, void *addr);
  54.  
  55. /*
  56.  * This is the ldt that every process will get unless we need
  57.  * something other than this.
  58.  */
  59. extern struct desc_struct default_ldt;
  60.  
  61. #endif
  62.